/**
 * Created by Student haitaohuang on 2017/3/1.
 */
public class Haitaohuang_CountYou{
    public static void main(String[] args) {
        String str = "When you are old \n" +
                "Yeats\n" +
                "When you are old and grey and full of sleep, \n" +
                "And nodding by the fire, take down this book, \n" +
                "And slowly read, and dream of the soft look \n" +
                "Your eyes had once, and of their shadows deep; \n" +
                "How many loved your moments of glad grace, \n" +
                "And loved your beauty with love false or true, \n" +
                "But one man loved the pilgrim Soul in you, \n" +
                "And loved the sorrows of your changing face; \n" +
                "And bending down beside the glowing bars, \n" +
                "Murmur, a little sadly, how Love fled \n" +
                "And paced upon the mountains overhead \n" +
                "And hid his face amid a crowd of stars. \n";
        int count = 0;

        //        String regx = "(Y|y)(O|o)(U|u)(R|r){0,1}"; //1.0版本
        //1.1版本
        str  = str.toLowerCase();
        String regx = "you(r)?[^a-zA-Z]";//防止出現匹配其他单词，如：young,yourself.

        //对于每个出现的关键词，切割一次，所以出现n次字符，则共切割成n+1份
        count = str.split(regx).length - 1;

        System.out.println(count);
    }
}
